/**
 * 
 */
package lt.vin.ht.server.dao.impl;

import lt.vin.ht.server.dao.SrcDao;
import lt.vin.ht.shared.Src;

/**
 * @author vienozin
 * 
 */
public class SrcDaoImpl implements SrcDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * lt.vin.currency.server.converter.SrcDao#getSrcForUrl(java.lang.String)
	 */
	@Override
	public Src getSrcForUrl(String url) {
		Src result = new Src();

		result.setHost("http://www.couchsurfing.org");
		result.setPattern(".*");
		result.setSchemaId("Profile.xsd");
		result.setTransformation(xslt);

		return result;
	}

	private static final String xslt = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:string=\"http://exslt.org/strings\"><xsl:template match=\"/\"><profile xmlns:tns=\"http://www.couchcrowler.com/Profile\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.couchcrowler.com/Profile Profile.xsd\"><tns:id><xsl:value-of select=\"string:tokenize(//td[@class='botnav_15']/a/@href, '=')[2]\"></xsl:value-of></tns:id><tns:name><xsl:value-of select=\"//h1[@class='profile']\" /></tns:name><tns:localtion><tns:longitude><xsl:value-of select=\"string:tokenize(translate(//a[@target='mapquest'], 'Laton: ', ''), ',')[2]\" /></tns:longitude><tns:latitude><xsl:value-of select=\"string:tokenize(translate(//a[@target='mapquest'], 'Laton: ', ''), ',')[1]\" /></tns:latitude></tns:localtion><tns:picture><xsl:value-of select=\"concat(concat(substring-before(//div[@align='center']/a/img/@src, '_m_'), '_t_'), substring-after(//div[@align='center']/a/img/@src, '_m_'))\" /></tns:picture><tns:contacts><xsl:for-each select=\"//td[@class='friends']\"><xsl:if test=\"./a/img/@src\"><tns:id><xsl:value-of select=\"string:tokenize(./a/img/@src, '/')[3]\" /></tns:id></xsl:if></xsl:for-each></tns:contacts></profile></xsl:template></xsl:stylesheet>";

}
